//
//  PVGoodsCell.m
//  wedding
//
//  Created by 常宽 on 15/1/27.
//  Copyright (c) 2015年 常宽. All rights reserved.
//

#import "PVGoodsCell.h"
#import "GoodsModel.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface PVGoodsCell ()

@property (nonatomic, retain)UIImageView *myImageView;
@property (nonatomic, retain)UILabel *likeCount;
@property (nonatomic, retain)UILabel *price;

@end

@implementation PVGoodsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.myImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.myImageView];
        
        self.likeCount = [[UILabel alloc] init];
        [self.contentView addSubview:self.likeCount];
        
        self.price = [[UILabel alloc] init];
        [self.contentView addSubview:self.price];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.myImageView.frame = CGRectMake(5, 5, WIDTH - 10, HEIGHT - 10);
    [self.myImageView sd_setImageWithURL:[NSURL URLWithString:self.model.photo_path] placeholderImage:[UIImage imageNamed:@"NoPicture.jpg"]];
    _myImageView.clipsToBounds = YES;
    _myImageView.layer.cornerRadius = 10;
    _myImageView.contentMode = UIViewContentModeScaleAspectFill;
    
    //醒目
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(22, 15, 3, 20)];
    view.backgroundColor = [WebColor crimson];
    [self addSubview:view];
    
    self.likeCount.frame = CGRectMake(25, 15, 60, 10);
    self.likeCount.font = [UIFont boldSystemFontOfSize:10.f];
    self.likeCount.backgroundColor = [[WebColor white]colorWithAlphaComponent:0.6];
    self.likeCount.text = [NSString stringWithFormat:@" ❤️ %@", self.model.like_count];
    
    self.price.frame = CGRectMake(25, 25, 60, 10);
    self.price.font = [UIFont boldSystemFontOfSize:10.f];
    self.price.backgroundColor = [[WebColor white]colorWithAlphaComponent:0.6];
    self.price.text = [NSString stringWithFormat:@" ￥ %@", self.model.price];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
